package com.dxf.chepter04

import scala.reflect.internal.util.StringOps

/**
 *
 *
 *
 *
 *
 */
object T42_作业 {
  def main(args: Array[String]): Unit = {

    //println({}, {}.getClass)
     t03_2(1)
   // t06("Hello")
  // println(t08("Hello",1))

  }


  def t01(n1: Int): Unit = {

  }

  def t02(n1: Int): Unit = {
    "() void"
  }

  def t03(n1: Int): Unit = {
    for (i <- Range(10, 0, -1)) {
      println(i)
    }
  }

  def t03_2(n1: Int): Unit = {
    for (i <- 0 to 10 reverse) {
      println(i)
    }
  }

  def t04(str: String): Unit = {
    var sum = 1L
    for (temp <- str) {
      sum *= temp.toLong
    }
    println(sum)
  }

  def t05(str: String): Unit = {
    var sum = 1L
    str.foreach(ch => {
      sum *= ch.toLong
    })
    println(sum)
  }

  def t06(str: String): Unit = {
    var sum = 1L
//    str.foreach(ch => {
//      sum *= ch.toLong
//    })
    //_ 表示所有的每一个值.foreach 高阶函数,传入函数,可以简写
    str.foreach(sum *= _.toLong)
    println(sum)
  }

  def t07(str: String): Unit = {
    var sum = 1L
    str.foreach(ch => {
      sum *= ch.toLong
    })
    println(sum)
  }

  def t08(str: String, sum: Long): Long = {
    var _sum =sum
    if (str.length == 1) {
      return sum * str.charAt(0).toLong
    } else {
      _sum *= str.charAt(0).toLong
      t08(str.substring(1),_sum)
    }

  }

}



